package com.bianguo.android.functiondemo.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bianguo.android.functiondemo.R;
import com.bianguo.android.functiondemo.utils.GlideUtil;

import java.util.ArrayList;

import butterknife.BindView;

public class ReptileAdapter extends BaseRecyclerAdapter<String> {

    public ReptileAdapter(Context mContext, ArrayList<String> list) {
        super(mContext, list);
    }

    @Override
    public BaseViewHolder createHolder(@NonNull ViewGroup viewGroup, int viewType) {
        View view = inflater.inflate(R.layout.item_reptile_layout, viewGroup, false);
        return new ViewHolder(view);
    }

    @Override
    public void bindHolder(@NonNull BaseViewHolder baseViewHolder, int position) {
        ViewHolder viewHolder = (ViewHolder) baseViewHolder;
        GlideUtil.loadImage(mContext, list.get(position), viewHolder.imageView, -1);
        viewHolder.imageView.setOnClickListener(view -> {
            if (onClickItemListener != null) {
                onClickItemListener.onClickItemListener(this, view, viewHolder.getLayoutPosition());
            }
        });
    }

    public static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.item_reptile_image)
        ImageView imageView;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}
